﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Linq;
using DTOAuction;
using System.Configuration;

namespace DAOAuction
{
    public class DAOKhoa
    {
        public List<KHOA_getallResult> layDanhSachTatCaKhoa()
        {
            List<KHOA_getallResult> lstKhoa = new List<KHOA_getallResult>();
            using (LinqDataContext db = new LinqDataContext(global::DAOAuction.Properties.Settings.Default.QUANLYGIAODUCConnectionString))
            {
                ISingleResult<KHOA_getallResult> lp = db.KHOA_getall();
                foreach (KHOA_getallResult khoa in lp)
                {
                    KHOA_getallResult var1 = new KHOA_getallResult();
                    var1.MAKHOA = khoa.MAKHOA;
                    var1.TENKHOA = khoa.TENKHOA;
                    lstKhoa.Add(var1);
                }
                try
                {
                    // Save the changes.
                    db.SubmitChanges();
                }
                // Detect concurrency conflicts.
                catch (ChangeConflictException)
                {
                    // Resolve conflicts.
                    db.ChangeConflicts.ResolveAll(RefreshMode.KeepChanges);
                }
            }
            return lstKhoa;
        }
    }
}